@echo off
setlocal

REM UTF8编码
chcp 65001

REM 设置GitHub仓库URL和目标目录

git config --global user.name 'awn-tseng'
git config --global user.email 'zengwen.chu@qq.com'
git config --global user.password "QADLPWYYAN520"

set REPO_URL=https://gitee.com/awn-tseng/uni-scm.git
set TARGET_DIR=C:\scm\source\scm_uni
set OUTPUT_DIR=C:\scm\assets\hotkit

REM 克隆GitHub仓库到指定目录
rmdir /s /q "%TARGET_DIR%"
echo Removing "%TARGET_DIR%"

if not exist "%TARGET_DIR%" mkdir "%TARGET_DIR%"
cd /d "%TARGET_DIR%"
git clone %REPO_URL% .

REM 检查是否成功克隆了仓库
if errorlevel 1 (
    echo Git Clone Failed. Aborting.
    goto :EOF
)

REM 删除unpackage文件夹
rmdir /s /q "%TARGET_DIR%\unpackage"

REM 对文件进行打包
powershell.exe -Command "Compress-Archive -Path '%TARGET_DIR%\*' -DestinationPath '%TARGET_DIR%\scm.zip'"

REM 文件改名为WGT包
move /Y "%TARGET_DIR%\scm.zip" "%OUTPUT_DIR%\scm.wgt"

endlocal
exit
